package Blocks;

import java.util.BitSet;
import java.util.Iterator;
import java.util.LinkedList;

public class Block extends GeneralBlock {
	private LinkedList<NextState> node;

	private boolean endBlock;

	public Block() {
		node = new LinkedList<NextState>();
		endBlock = true;
	}

	public Block(LinkedList<NextState> startState) {
		node = startState;
		endBlock = true;
	}

	public LinkedList<NextState> getNode() {
		return node;
	}

	public void setNode(LinkedList<NextState> node) {
		this.node = node;
	}

	public boolean isEndBlock() {
		return endBlock;
	}

	public void setEndBlock(boolean endBlock) {
		this.endBlock = endBlock;
	}



	public void add(int nextState, char curroutput, String output) {
		String newOutput = output;
		newOutput= newOutput+curroutput;
		Iterator<NextState> it = node.iterator();
		boolean check = false;
		while (it.hasNext()) {
			NextState curr = it.next();
			if (newOutput.equals(curr.getOutput())) {
				curr.getNextState().set(nextState);
				check = true;
				endBlock=false;
				break;
			}
		}
		if (!check) {
			NextState newState = new NextState(nextState, output, curroutput);
			node.add(newState);
		}
	};
	public static void main(String[] args) {
		
	}
}
